class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        unordered_map<string, vector<string>> hash;
        for (auto a : strs)
        {
            string s = a;
            sort(s.begin(), s.end());
            hash[s].push_back(a);
        }

        vector<vector<string>> ret;
        for (auto& ch : hash)
        {
            ret.push_back(ch.second);
        }
        return ret;
    }
};